// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async(event, context) => {
  const wxContext = cloud.getWXContext()

  const db = cloud.database()
  const clubco = db.collection("club")
  try {
    return await clubco.doc(event.club.id).update({
      data: {
        name: event.club.name,
        slogan: event.club.slogan,
        profile: event.club.profile,
        type: event.club.type,
        contact: event.club.contact,
        pictures:event.club.pictures,
        avatar:event.club.avatar
      }
    })
  } catch (err) {
    console.log(err)
  }
  return {
    event,
    openid: wxContext.OPENID,
    appid: wxContext.APPID,
    unionid: wxContext.UNIONID,
  }
}